package com.avocado.mailBox.impl;

import com.avocado.mailBox.MailBox;
import com.avocado.message.Message;

import java.util.ArrayDeque;

/**
 * @author avocado
 * @date 2023/5/28 22:25
 */
public class QueueMailBox implements MailBox {

    private final ArrayDeque<Message> deque;

    public QueueMailBox(int size) {
        this.deque = new ArrayDeque<Message>(size);
    }

    public Message poll() {
        return deque.poll();
    }

    public void offer(Message message) {
        deque.offer(message);
    }

    public int size() {
        return deque.size();
    }

    public boolean isEmpty() {
        return deque.isEmpty();
    }

    public void clear() {
        deque.clear();
    }
}
